﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Maticsoft.DBUtility;

namespace ElingOA6_DSJCJ.DAL
{
    /// <summary>
    /// 友情链接明细 数据类
    /// </summary>
    public class LinkTypeEntry
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public LinkTypeEntry()
        {
        }
        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-09-09</date>
        /// </summary>
        public DataSet GetListByLinkType(string entityNo, string linkTypeCD)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select FLinkTypeEntryID,FLinkText,FDispSeq,FLinkURL,FOldFileName,FNewFileName,FExtName,FFileContent,FLinkTypeCD,FEntityNo ");
            strSql.Append(" FROM t_LinkTypeEntry ");
            strSql.Append(" WHERE FLinkTypeCD=@FLinkTypeCD AND FEntityNo=@FEntityNo");
            strSql.Append(" ORDER BY FDispSeq");
            SqlParameter[] parameters = {
					new SqlParameter("@FLinkTypeCD", SqlDbType.NVarChar,6),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)};
            parameters[0].Value = linkTypeCD;
            parameters[1].Value = entityNo;
            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 得到一个对象实体
        /// <creator>wangl</creator>
        /// <date>2013-09-09</date>
        /// </summary>
        public Model.LinkTypeEntry DataRowToModel(DataRow row)
        {
            Model.LinkTypeEntry model = new Model.LinkTypeEntry();
            if (row != null)
            {
                if (row["FLinkTypeEntryID"] != null && row["FLinkTypeEntryID"].ToString() != "")
                {
                    model.FLinkTypeEntryID = int.Parse(row["FLinkTypeEntryID"].ToString());
                }
                if (row["FLinkText"] != null)
                {
                    model.FLinkText = row["FLinkText"].ToString();
                }
                if (row["FDispSeq"] != null && row["FDispSeq"].ToString() != "")
                {
                    model.FDispSeq = int.Parse(row["FDispSeq"].ToString());
                }
                if (row["FLinkURL"] != null)
                {
                    model.FLinkURL = row["FLinkURL"].ToString();
                }
                if (row["FOldFileName"] != null)
                {
                    model.FOldFileName = row["FOldFileName"].ToString();
                }
                if (row["FNewFileName"] != null)
                {
                    model.FNewFileName = row["FNewFileName"].ToString();
                }
                if (row["FExtName"] != null)
                {
                    model.FExtName = row["FExtName"].ToString();
                }
                if (row["FFileContent"] != null && row["FFileContent"].ToString() != "")
                {
                    model.FFileContent = (byte[])row["FFileContent"];
                }
                if (row["FLinkTypeCD"] != null)
                {
                    model.FLinkTypeCD = row["FLinkTypeCD"].ToString();
                }
                if (row["FEntityNo"] != null)
                {
                    model.FEntityNo = row["FEntityNo"].ToString();
                }
            }
            return model;
        }
    }
}
